package com.lantosec.hmrp.modules.warning.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.warning.vo.WarningRuleVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * <p>
 * 预警规则 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-05-19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WarningRule extends BaseEntity<WarningRuleVO> {

    private static final long serialVersionUID = 1L;
    public WarningRule(WarningRuleVO vo){
        this.ruleId = vo.getRuleId();
        this.ruleName = vo.getRuleName();
        this.typeId = vo.getTypeId();
        this.warningGrade = vo.getWarningGrade();
        this.dataSourceType = vo.getDataSourceType();
        this.dataSource = vo.getDataSource();
        this.runCycleType = vo.getRunCycleType();
        this.runMonth = vo.getRunMonth();
        this.runDay = vo.getRunDay();
        this.runHour = vo.getRunHour();
        this.runMinute = vo.getRunMinute();
        this.startDate = vo.getStartDate();
        this.endDate = vo.getEndDate();
        this.tableDefine = vo.getTableDefine();
        this.repeatFilterSql = vo.getRepeatFilterSql();
        this.repeatFilterField = vo.getRepeatFilterField();
        this.thresholdValue = vo.getThresholdValue();
        this.disposalMode = vo.getDisposalMode();
        this.deptField = vo.getDeptField();
        this.userField = vo.getUserField();
        this.dataTimeField = vo.getDataTimeField();
        this.createUserId = vo.getCreateUserId();
        this.createUser = vo.getCreateUser();
        this.createTime = vo.getCreateTime();
        this.editUserId = vo.getEditUserId();
        this.editUser = vo.getEditUser();
        this.editTime = vo.getEditTime();
        this.flag = vo.getFlag();
        this.repeal = vo.getRepeal();
        this.chargeDept = vo.getChargeDept();

    }

    @Override
    public WarningRuleVO convertToVO(){
        return new WarningRuleVO(this);
    }


    /**
     * 预警规则ID
     */
    @TableId(value = "rule_id", type = IdType.ASSIGN_UUID)
    private String ruleId;

    /**
     * 预警规则名称
     */
    private String ruleName;

    /**
     * 预警类型ID
     */
    private String typeId;

    /**
     * 预警等级(1一级2二级3三级)
     */
    private Integer warningGrade;

    /**
     * 数据源类型(1SQL匹配)
     */
    private Integer dataSourceType;

    /**
     * 数据源
     */
    private String dataSource;

    /**
     * 运行周期类型(1定时2及时)
     */
    private Integer runCycleType;

    /**
     * 运行指定月份
     */
    private Integer runMonth;

    /**
     * 运行指定日期
     */
    private Integer runDay;

    /**
     * 运行指定小时
     */
    private Integer runHour;

    /**
     * 运行指定分钟
     */
    private Integer runMinute;

    /**
     * 运行开始日期
     */
    private String startDate;

    /**
     * 运行结束日期
     */
    private String endDate;

    /**
     * 预警数据表格定义JSON
     */
    private String tableDefine;

    /**
     * 重复过滤SQL
     */
    private String repeatFilterSql;

    /**
     * 重复过滤字段列表,分隔
     */
    private String repeatFilterField;

    /**
     * 阀值列表,分隔
     */
    private String thresholdValue;

    /**
     * 处置方式(1普通处置2考评处置)
     */
    private Integer disposalMode;

    /**
     * 部门字段定义
     */
    private String deptField;

    /**
     * 用户字段定义
     */
    private String userField;

    /**
     * 数据时间字段定义
     */
    private String dataTimeField;

    /**
     * 创建人ID
     */
    private String createUserId;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改人ID
     */
    private String editUserId;

    /**
     * 修改人
     */
    private String editUser;

    /**
     * 修改时间
     */
    private Date editTime;

    /**
     * 处置科室
     */
    private String chargeDept;

    /**
     * 废止标识 0启用1禁止
     */
    private Integer repeal;

    private Integer flag;


    public enum ColName {
        rule_id, rule_name, type_id, warning_grade, data_source_type, data_source, run_cycle_type, run_month, run_day, run_hour, run_minute, start_date, end_date, table_define, repeat_filter_sql, repeat_filter_field, threshold_value, disposal_mode, dept_field, user_field, data_time_field, create_user_id, create_user, create_time, edit_user_id, edit_user, edit_time, 
    }
}
